home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Over 1,000 Windows 95 Programs
/
Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso
/
1257
/
conv.c_
/
conv.c
Wrap
C/C++ Source or Header
|
1997-04-18
|
3KB
|
126 lines
/* EasyCODE(C++) V5.1 02.03.1995 13:54:02 */
/* EasyCODE O
If=horizontal
LevelNumbers=no
LineNumbers=no
ScreenFont=Courier New,,80,9220,-11,0,400,0,0,0,0,0,0,3,2,1,49
PrinterFont=Courier New,,80,17414,-34,0,400,0,0,0,0,0,0,3,2,1,49
LastLevelId=16 */
/* EasyCODE ( 1
conv.c */
/* EasyCODE ( 13
Includes, Externals */
#include "conv.h"
extern char* TABLE[ETF_LASTKEYWORD];
/* EasyCODE ) */
/* EasyCODE ( 14
GetChar */
/* EasyCODE F */
char GetChar()
// Delivers next character from read buffer
{
return (inbuf[inbufPos++]);
}
/* EasyCODE ) */
/* EasyCODE ( 15
GetKeyword */
/* EasyCODE F */
int GetKeyword(char* delimiter, char* contents)
// Delivers ID of keyword of line in buffer;
// Delimiter and content (if there is one) are also delivered.
{
char keyword[MAX_KEYWORDLEN+1];
int wordPos;
/* EasyCODE - */
int i;
char ch;
/* EasyCODE - */
inbufPos = 0;
wordPos = 0;
*contents = '\0';
*delimiter = ';';
*(delimiter+1) = '\0';
memset(keyword, '\0', sizeof(keyword));
/* EasyCODE - */
ch = GetChar();
/* EasyCODE - */
// Skip white spaces before keyword
while (ch == ' ')
{
ch = GetChar();
}
// If line is empty return NO_KEYWORD
if (((ch == '\r')||(ch == '\n')))
{
return (NO_KEYWORD);
}
// Extract keyword
while (isalnum((int) ch))
{
keyword[wordPos++] = ch;
ch=GetChar();
}
// If unexpected EOF return EOF_KEYWORD
if (ch == EOF)
{
return (EOF_KEYWORD);
}
// Check whether keyword is valid
for (i=0;i<=ETF_LASTKEYWORD;i++)
{
if (strcmp(keyword,TABLE[i]) == 0)
{
break;
}
}
// If invalid keyword return ERROR_KEYWORD
if (i>ETF_LASTKEYWORD)
{
return (ERROR_KEYWORD);
}
// If delimiter "=" or ":", deliver content
if ((ch == '=') || (ch == ':'))
{
*delimiter=ch;
/* EasyCODE - */
ch = GetChar();
while (ch != '\0')
{
if (ch == EOF)
{
return (EOF_KEYWORD);
}
*contents++ = ch;
ch = GetChar();
}
*contents='\0';
}
// printf("%s",inbuf);
/* EasyCODE - */
// Return valid keyword
return (i);
}
/* EasyCODE ) */
/* EasyCODE ( 16
err_msg */
/* EasyCODE F */
void err_msg(int lineNum, char* text)
// Prints error message
{
printf("Line %d: %s\n", lineNum, text);
}
/* EasyCODE ) */
/* EasyCODE ) */